/*
	project01.h
	Author: Pedro J. Toro
	E-Mail: ptoro1@worcester.edu
	Program: Project01
	CSC 8009 Network Security
	03/05/2008
*/

/*  This is the header file for project01 */

#ifndef PROJECT01_H
#define PROJECT01_H

#include <stdio.h>				/* standard header file */

#define ENCRYPT "-e"
#define DECRYPT "-d"
#define KEYSIZE 10
#define BLOCKSIZE 8
#define TRUE 1
#define FALSE 0


/* Displays the proper syntax for using the program.
*/
void usageSummary();

/* Checks if the key is a valid format.
*/
int validKeyFormat(unsigned char key[]);

/* Converts a character into an 8 "bit" representation using an array of characters.
*/
void convertTo8Bits(unsigned char letter, unsigned char _8bits[]);

/* Converts an array of 8 characters into a character.
*/
unsigned char convertToChar(unsigned char _8bits[]);

/*********** S-DES Key Generation ***********/
/* Generates the two keys used for encryption/decryption.
*/
void genKeys(unsigned char key[], unsigned char *k1, unsigned char *k2);

/* P10 permutaion
*/
void P10(unsigned char _10bits[]);

/* Circular left shift
*/
void LS(unsigned char _10bits[]);

/* P8 permutation
*/
void P8(unsigned char p10[], unsigned char p8[]);
/*********** S-DES Key Generation ***********/

/*********** S-DES Encryption/Decryption ***********/
/* Encrypt the given plaintext and return a cyphertext.
*/
unsigned char encrypt(unsigned char plaintext, unsigned char *k1, unsigned char *k2);

/* IP permutation
*/
void IP(unsigned char _8bits[]);

/* fK function
*/
void fK(unsigned char ip[], unsigned char k1[]);

/* E/P permutation
*/
void EP(unsigned char _4bits[], unsigned char ep[]);

/* S0 S-Box
*/
void S0(int x, int y, unsigned char _2bits[]);

/* S1 S-Box
*/
void S1(int x, int y, unsigned char _2bits[]);

/* P4 permutation
*/
void P4(unsigned char _4bits[]);

/* Interchanges the leftmost 4 "bits" with the rightmost 4 "bits".
*/
void SW(unsigned char _8bits[]);

/* inverse IP permutation
*/
void IP_inv(unsigned char _8bits[]);
/*********** S-DES Encryption/Decryption ***********/

#endif